<!--
 - MineAdmin is committed to providing solutions for quickly building web applications
 - Please view the LICENSE file that was distributed with this source code,
 - For the full copyright and license information.
 - Thank you very much for using MineAdmin.
 -
 - @Author X.Mo<root@imoi.cn>
 - @Link   https://gitee.com/xmo/mineadmin-vue
-->
<template>
  <div class="ma-content-block  justify-between p-4">




    <ma-form
        ref="formRef"
        v-model="form"
        :columns="columns"
        class="mt-7"
        @submit="submitConfig"
    ></ma-form>





  </div>
</template>

<script setup>
import { ref, reactive, onMounted, watch } from 'vue'
import MaUpload from '@cps/ma-upload/index.vue'
import infoClass from '@/api/info/infoClass'
import { Message } from '@arco-design/web-vue'
const initData=async ()=> {
  const response = await infoClass.getInitConfig();
  form.value.company_addr=response.data.company_addr
  form.value.company_link=response.data.company_link
  form.value.company_addr_img=response.data.company_addr_img
  form.value.company_email=response.data.company_email
  form.value.company_en_name=response.data.company_en_name
  form.value.company_name=response.data.company_name

  form.value.company_tel=response.data.company_tel

  form.value.code_body=response.data.code_body

}
initData();
const submitConfig = async ({ values, errors }) => {
  const response=await infoClass.submitConfig(form.value);
  if(response.success){
    Message.success(response.message)
  }else{
    Message.error(response.message)
  }
}

const form = ref({
  company_name:'',
  company_en_name:'',
  company_tel:'',
  company_email:'',
  company_addr:'',
  company_addr_img:'',
  company_official_img:'',
  company_tiktok_img:'',
  company_red_img:'',
  code_body:''
})
const columns = reactive([
  {
    title: "公司名称",
    dataIndex: "company_name",
    width:280,
    formType: "input",
    editDisplay: false,
    hide:true
  },
  {
    title: '公司英文名',
    dataIndex: 'company_en_name',
    formType:'input',

  },
  {
    title: "公司电话",
    dataIndex: "company_tel",
    formType: "input",
    hide: true
  },
  {
    title: "公司邮箱",
    dataIndex: "company_email",
    formType: "input",
    hide: true
  },
  {
    title: "公司地址",
    dataIndex: "company_addr",
    formType: "input",
    hide: true
  },
  {
    title: "公司联接",
    dataIndex: "company_link",
    formType: "input",
    hide: true
  },
  {
    title: "公司地址图",
    dataIndex: "company_addr_img",
    formType: "upload",
    onlyData: true,
    returnType: "url",
    multiple: false,
    chunk: false,
    type: "image",
    hide: true
  },
   {
    title: '二维码',
    dataIndex: 'code_body',
    formType: 'children-form',
    type: 'table',
    formList: [
      {
        dataIndex: 'img', title: '二维码',  formType: "upload",
        onlyData: true,
        returnType: "url",
        multiple: false,
        chunk: false,
        type: "image"
      },
      {
        dataIndex: 'title', title: '说明', formType: 'input',
      }
    ],
    hide: true
  }
  ])





</script>
<script>
export default { name: 'userCenter' }
</script>

<style scoped>
.avatar-box {
  width: 130px;
}
.user-header {
  width: 100%;
  height: 200px;
  background: url('@/assets/userBanner.jpg') no-repeat;
  background-size: cover;
}
</style>
